/**
 *
 */
package main;

import java.util.concurrent.*;


/**
 * @author kin
 *
 */
public class integral {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

		double x_l, x_r;
		double stepI;
		
		
		
		stepI=0.0001;
		x_l = 12;
		x_r = 18;
		
		
		Summ result = new Summ(0);
		
			
		ExecutorService executor = Executors.newFixedThreadPool(3);

		double interval;
		interval = (x_r-x_l)/10;
		double x1,x2;
		for (int i=0; i<10; i++) {
			 x1=x_l+i*interval;
			 x2=x_l+(i+1)*interval;
	         Runnable runner = new runIntegral(x1,x2,stepI,result);
	         executor.execute(runner);
	       }
		    
		 
			try
			{
				executor.shutdown();
				executor.awaitTermination(10, TimeUnit.MINUTES);
			}
			catch (InterruptedException e)
			{
				System.out.println("Прерывание");
			}
			

		System.out.println("Результат: "+ result.getSumm());
		
			
	}

	}


